import 'package:flutter/material.dart';
import 'package:flutter_app/values/MyColors.dart';
import 'package:flutter_app/widget/custom_app_bar.dart';
import 'package:flutter_screenutil/src/size_extension.dart';
import 'package:get/get.dart';

import '../../../r.dart';
import 'password_change_logic.dart';
/**
 * @Description: 修改密码
 * @Author: 下雨了
 * @CreateDate: 2022-6-20 17:49:26
 * @Version: 1.0
 */
///
class PasswordChangePage extends StatefulWidget {
  final String title;

  const PasswordChangePage({Key? key, required this.title}) : super(key: key);

  @override
  _PasswordChangePageState createState() => _PasswordChangePageState();
}

class _PasswordChangePageState extends State<PasswordChangePage> {
  final logic = Get.put(PasswordChangeLogic());
  final state = Get.find<PasswordChangeLogic>().state;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<PasswordChangeLogic>(builder: (logic) {
      return Scaffold(
        backgroundColor: MyColors.FFF1F1F1,
        appBar: MyAppBar(context, title: "修改密码"),
        body: Column(
          children: [
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 8.r, 20.r, 8.r),
              child: Row(
                children: [
                  Image.asset(R.assetsImgIcon41, width: 18.r,),
                  SizedBox(width: 10.r,),
                  Expanded(
                    child: TextField(
                      controller: logic.oldPassword,
                      autofocus: false,
                      obscureText: true,
                      style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp),
                      decoration: InputDecoration(
                        //不需要输入框下划线
                          border: InputBorder.none,
                          hintText: '请输入原密码',
                          hintStyle: TextStyle(color: MyColors.FF999999)),
                    ),
                  ),
                ],
              ),
            ),
            Divider(
              height: 0.5,
              thickness: 1,
              color: MyColors.FFF5F5F5,
            ),
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 8.r, 20.r, 8.r),
              child: Row(
                children: [
                  Image.asset(R.assetsImgIcon42, width: 18.r,),
                  SizedBox(width: 10.r,),
                  Expanded(
                    child: TextField(
                      controller: logic.password,
                      autofocus: false,
                      obscureText: true,
                      style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp),
                      decoration: InputDecoration(
                        //不需要输入框下划线
                          border: InputBorder.none,
                          hintText: '请设置新密码',
                          hintStyle: TextStyle(color: MyColors.FF999999)),
                    ),
                  ),
                ],
              ),
            ),
            Divider(
              height: 0.5,
              thickness: 1,
              color: MyColors.FFF5F5F5,
            ),
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 8.r, 20.r, 8.r),
              child: Row(
                children: [
                  Image.asset(R.assetsImgIcon43, width: 18.r,),
                  SizedBox(width: 10.r,),
                  Expanded(
                    child: TextField(
                      controller: logic.password2,
                      autofocus: false,
                      obscureText: true,
                      style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp),
                      decoration: InputDecoration(
                        //不需要输入框下划线
                          border: InputBorder.none,
                          hintText: '请确认新密码',
                          hintStyle: TextStyle(color: MyColors.FF999999)),
                    ),
                  ),
                ],
              ),
            ),
            Divider(
              height: 0.5,
              thickness: 1,
              color: MyColors.FFF5F5F5,
            ),
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 90.r, 20.r, 0),
              height: 50.r,
              width: MediaQuery.of(context).size.width,
              child: ElevatedButton(
                child: Text("修改", style: TextStyle(color: MyColors.FFFFFFFF, fontSize: 14),),
                style: ButtonStyle(
                  padding: MaterialStateProperty.all(EdgeInsets.all(0)),
                  backgroundColor: MaterialStateProperty.all<Color>(MyColors.FFE5261E),
                  shape:  MaterialStateProperty.all(
                    RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(5)),
                    ),
                  ),
                ),
                onPressed: () {
                  logic.updateLoginPassword();
                },
              ),
            ),
          ],
        ),
      );
    });
  }

  @override
  void dispose() {
    Get.delete<PasswordChangeLogic>();
    super.dispose();
  }
}
